<?php session_start(); ?>
<?php include("./function.php"); ?>
<?php include("./config.php"); ?>
<?php 
	$form = 1;
	$error = 0;
	$email = "mail@host";
	$pass = "password";
	$repass = "password";
	$code = "";
	if (isset($_POST['email'])) {
		if (empty($_POST['email']))
		{
			$error += 1;
		}
		else
		{
			$email = $_POST['email'];
		}
		if (empty($_POST['pass']))
		{
			$error += 2;
		}
		else
		{
			$pass = $_POST['pass'];
		}
		if (empty($_POST['repass']))
		{
			$error += 4;
		}
		else
		{
			$repass = $_POST['repass'];
		}
		if (empty($_POST['code']))
		{
			$error += 8;
		}
		else
		{
			$code = $_POST['code'];
		}
		if (@$_POST['email'] == "admin@admin")
		{
			$error += 16;
		}
		if (@$_POST['pass'] != @$_POST['repass'])
		{
			$error += 32;
		}
		if (@$_POST['code'] != $_SESSION['code'])
		{
			$error += 64;
		}
		if ($error == 0)
		{
			$form = 0;
		}
		else
		{
			error($error);
		}
	}
	$_SESSION['code'] = substr(md5(rand(0,1000)), 0, 5);
?>
<?php if(true) : ?>
<html>
	<head>
		<title><?php print($conf['title']); ?>::Register</title>
	</head>
	<body>
		<a href="./">Back</a><br>
<?php if(!empty($form)) : ?>
		<form name="register" method="POST">
			<table border="0">
				<tr>
					<td>Login:</td>
					<td><input name="email" id="email" type="text" value="<?php print($email); ?>"></td>
				</tr>
				<tr>
					<td>Password:</td>
					<td><input name="pass" id="pass" type="password" value="<?php print($pass); ?>"></td>
				</tr>
				<tr>
					<td>Re-Password:</td>
					<td><input name="repass" id="repass" type="password" value="<?php print($repass); ?>"></td>
				</tr>
			<tr>
				<td colspan="2" align="center"><img src="./img.php"></td>
			</tr>
			<tr>
				<td>Code:</td>
				<td><input name="code" id="code" type="text" value="<?php print($code); ?>"></td>
			</td>
			<tr>
				<td align="center" colspan="2"><input type="submit" value="Register"></td>
			</tr>
			</table>
		</form>
<?php endif; ?>
	</body>
</html>
<?php endif; ?>